import 'package:flutter/material.dart';
import 'package:flutter_app_study/fragment/home/ChartsFragment.dart';
import 'package:flutter_app_study/fragment/home/HotFragment.dart';
import 'package:flutter_app_study/fragment/home/SerialNumberFragment.dart';
import 'package:flutter_app_study/fragment/home/ZhiBoFragment.dart';
import 'package:flutter_app_study/utils/ImageUtil.dart';
import 'package:flutter_app_study/view/LineView.dart';

class HomePageOne extends StatefulWidget {
  @override
  _HomePageOneState createState() => _HomePageOneState();
}

class _HomePageOneState extends State<HomePageOne>
    with SingleTickerProviderStateMixin {
  var _tabControler;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabControler = TabController(length: 5, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[
          Container(
            height: 40,
            child: TabBar(
              labelColor: Colors.white54,
              indicatorColor: Colors.red,
              indicatorSize: TabBarIndicatorSize.tab,
              tabs: <Widget>[
                Text(
                  "推介",
                  style: TextStyle(color: Colors.black),
                ),
                Text(
                  "热门",
                  style: TextStyle(color: Colors.black),
                ),
                Text(
                  "追番",
                  style: TextStyle(color: Colors.black),
                ),
                Text(
                  "国家",
                  style: TextStyle(color: Colors.black),
                ),
                Text(
                  "故事",
                  style: TextStyle(color: Colors.black),
                ),
              ],
              controller: _tabControler,
            ),
          ),
          LineView(),
          Expanded(
              child: TabBarView(
            children: <Widget>[
              ZhiBoFragment(),
              HotFragment(),
              SerialNumberFragment(),
              ChartsFragment(),
              CarouselImage(),
            ],
            controller: _tabControler,
          )),
        ],
      ),
    );
  }
}

class CarouselImage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(bottom: 50),
      child: ClipRRect(
        borderRadius: BorderRadius.all(Radius.circular(20)),
        child: Image.asset(
          ImageUtil.getImageAsset("lonnv10.jpg"),
          fit: BoxFit.cover,
        ),
      ),
    );
  }
}
